Namespacing everything to /UVa.
[andmenj-acm.git] / UVa / 686 - Goldbach's conjecture (II) / 686.cpp
blob9de21ab6387413d133b49f5c120c082f42a9812c
1 using namespace std;
2 #include <algorithm>
3 #include <iostream>
4 #include <iterator>
5 #include <sstream>
6 #include <fstream>
7 #include <cassert>
8 #include <climits>
9 #include <cstdlib>
10 #include <cstring>
11 #include <string>
12 #include <cstdio>
13 #include <vector>
14 #include <cmath>
15 #include <queue>
16 #include <deque>
17 #include <stack>
18 #include <list>
19 #include <map>
20 #include <set>
22 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
23 #define For(i, a, b) for (int i=(a); i<(b); ++i)
24 #define D(x) cout << #x " is " << x << endl
26 const int MAXN = 1 << 15 + 5;
27 bool prime[MAXN];
29 int main(){
30 memset(prime, true, sizeof prime);
31 prime[0] = prime[1] = false;
32 for (int i=4; i<MAXN; i += 2) prime[i] = false;
33 for (int i=3; i<MAXN; i += 2){
34 if (prime[i]){
35 for (int j=i+i; j<MAXN; j += i) prime[j] = false;
39 int n;
40 while (scanf("%d", &n)==1 && n){
41 int m = n / 2, ans = prime[n-2];
42 for (int a = 3; a <= m; a += 2){
43 ans += (prime[a] && prime[n-a]);
45 printf("%d\n", ans);
47 return 0;